home *** CD-ROM | disk | FTP | other *** search
- /* sopen.c --- p 505 */
- #include <stdio.h>
- #include <io.h>
- #include <fcntl.h>
- #include <share.h>
- #include <sys\stat.h>
- main()
- {
- int fhandle1, fhandle2;
- /* Open the file "autoexec.bat." */
- if ( (fhandle1 = sopen("c:\\autoexec.bat",
- O_RDONLY, SH_DENYRW, S_IREAD)) == -1)
- {
- perror("open failed");
- exit(1);
- }
- printf("AUTOEXEC.BAT opened once. Handle = %d\n", fhandle1);
- /* Now open again */
- if ( (fhandle2 = sopen("c:autoexec.bat",
- O_RDONLY, SH_DENYRW, S_IREAD)) == -1)
- {
- perror("open failed");
- printf("SHARE installed\n");
- exit(1);
- }
- printf("AUTOEXEC.BAT open again. Handle = %d\n", fhandle2);
- printf("SHARE has not been installed\n");
- }